<!--
Edgar Garibay Ruiz
is217618
14 de Septiembre 2011
Version 1

Clase Conection para manejar las conexiones a la base de datos
-->

<?php
	class Connection{
		public $User = "user2";
		public $Password = "12345";
		public $Server = "localhost";
		public $DB = "pae";		
		public $Success = false;
		
		function __construct($user,$pass,$server,$db){
			$this->User = $user ; 
			$this->Password = $pass;
			$this->Server = $server;
			$this->DB = $db;
		}
			
		public function doConnect(){
			$con = @mysql_connect($this->Server,$this->User,$this->Password);
						
			if (!$con){			
				$this->Success = false;
				return $con;
			}

			$db_selected = mysql_select_db($this->DB , $con);

			if (!$db_selected){
				$this->Success = false;
				mysql_close($con);
				return $con;
				
			}
			$this->Success = true;
			return $con;
		}
		
		public function getConnect(){
			return $this->Success;
		}
	}
	
	
	$connect = new Connection("user","12345","localhost","pae");
	echo $connect->doConnect()."<br>";
	echo $connect->getConnect();
?>